window.WpsClientTypeMap = {
  [WpsClientTypeEnum.表格]: window.EtUtils,
  [WpsClientTypeEnum.文档]: window.WpsUtils,
  [WpsClientTypeEnum.演示]: window.WppUtils,
};

class CommonUtilClass {
  /**
   * @type {WpsClientTypeEnum}
   */
  clientType;

  constructor(clientType) {
    this.clientType = clientType;
  }

  /**
   * 获取当前文档对象
   * @returns {EtWorkbook |  WpsDocument | WppPresentation}
   */
  getActionDto() {
    return WpsClientTypeMap[this.clientType].getActiveDto();
  }

  /**
   * 得到当前工作簿对象
   * @returns {EtWorkbooks |  WpsDocuments | WppPresentations}
   */
  getWorkDtos() {
    return WpsClientTypeMap[this.clientType].getWorkDtos();
  }

  // 关闭打开新文档
  closeOpenNewFile(filePath) {
    this.getActionDto().Close();
    this.getWorkDtos().Open(filePath);
  }

  openNewClientFile(){
    // 通过打开文件，但会有警告
    // wps.OAAssist.ShellExecute("C:\\Users\\langy\\Desktop\\test-open.xlsx",'ksowebstartupet');
  }
}

window.commonUtil = new CommonUtilClass();